import request from '@/api/request'

enum API {
	SEARCH_URL = '/search', // 关键字搜索接口
	CREATEGROUP_URL = '/create/group', // 创建群聊接口
	GETFRIENDLIST_URL = '/contacts/friend', // 获取好友列表接口
	GETGROUPLIST_URL = '/contacts/group', // 获取群列表接口

	GETUSERCONTACTHOMEINFO_URL = '/home/user', // 获取用户主页信息接口
	GETGROUPCONTACTHOMEINFO_URL = '/home/group', // 获取群主页信息接口
	ADDFRIEND_URL = '/friend/add', // 发送好友申请接口
	ADDGROUP_URL = '/group/add', // 发送入群申请接口

	GETFRIENDNOAGREE_URL = '/get/friend/noagree', // 获取好友申请列表接口
	GETGROUPNOAGREE_URL = '/get/group/noagree', // 获取群申请列表接口

	AGREEFRIEND_URL = '/friend/agree', // 同意好友申请接口
	AGREEGROUP_URL = '/group/agree' // 同意入群申请接口
}

// 群头像上传接口
export const reqUploadGroupPhoto = API.UPLOADGROUPPHOTO_URL

// 创建群接口
export const reqCreateGroup = (data: any) => {
	return request.post(API.CREATEGROUP_URL, data)
}

// 关键词搜索
export const reqSearch = (data: any) => {
	return request.post(API.SEARCH_URL, { keyword: data })
}

// 获取好友列表
export const reqGetFriendList = (data: any) => {
	return request.post(API.GETFRIENDLIST_URL, { userId: data })
}

// 获取群聊列表
export const reqGetGroupList = (data: any) => {
	return request.post(API.GETGROUPLIST_URL, { userId: data })
}

// 获取用户主页信息接口
export const reqGetUserInfo = (data: any) => {
	return request.get(`${API.GETUSERCONTACTHOMEINFO_URL}?_id=${data._id}&urlId=${data.urlId}`, {})
}

// 获取群聊主页信息
export const reqGetGroupContactHomeInfo = (data: any) => {
	return request.post(API.GETGROUPCONTACTHOMEINFO_URL, data)
}

// 发送好友申请接口
export const reqAddFriend = (data: any) => {
	return request.post(API.ADDFRIEND_URL, data)
}

// 同意入群申请接口

export const reqAgreeGroup = (data: any) => {
	return request.post(API.AGREEGROUP_URL, { userId: data.userOtherId, groupId: data.id })
}

// 获取好友申请列表
export const reqGetFriendNoagreeList = (data: any) => {
	return request.post(API.GETFRIENDNOAGREE_URL, { userId: data })
}

// 获取群聊申请列表
export const reqGetGroupNoagreeList = (data: any) => {
	return request.post(API.GETGROUPNOAGREE_URL, { userId: data })
}

// 同意好友申请
export const reqAgreeFriend = (data: any) => {
	return request.post(API.AGREEFRIEND_URL, data)
}

// 请求加入群聊
export const reqAddGroup = (data: any) => {
	return request.post(API.ADDGROUP_URL, data)
}
